package huoye.shops.huoye.mine.presenter;

import com.codeideology.android.lang.entity.Paging;

import java.util.List;

import huoye.shops.base.BasePresenter;
import huoye.shops.base.MineBaseJsonRequestCallback;
import huoye.shops.huoye.mine.model.AccountList;
import huoye.shops.huoye.mine.networt.MineService;
import huoye.shops.huoye.mine.view.IManageAccountView;
import huoye.shops.huoye.mine.view.IRecordPayRefreshView;
import huoye.shops.huoye.operation.model.ShopPrizeList;


/**
 * Created by uesr on 2017/7/19.
 */

public class ManageAccountPresenter extends BasePresenter<IManageAccountView> {

    private MineService mService;

    //获取商家管理账户列表
    public void getAccountList(final Paging paging){
        // view.showProcessingIndicator();
        mService.getAccountList(paging, new MineBaseJsonRequestCallback<AccountList>(AccountList.class) {

            @Override
            public void onSuccess(List<AccountList> list) {
                super.onSuccess(list);
                view.setDataSet(list,paging);
            }

            //网络请求失败
            @Override
            public void onFailure(String msg, String code, Throwable e) {
                super.onFailure(msg, code, e);
                view.makeToast(msg);
            }

            //加载结束
            @Override
            public void onNetworkFail() {
                super.onNetworkFail();
                view.onNetworkFail();
            }

            //加载中
            @Override
            public void onFinish() {
                super.onFinish();
                view.hideProcessingIndicator();
            }
        });
    }



    //删除账户
    public void deleteAccount(String deleteId){
        // view.showProcessingIndicator();
        mService.deleteAccount(deleteId, new MineBaseJsonRequestCallback<AccountList>(AccountList.class) {

            @Override
            public void onSuccess() {
                super.onSuccess();
                view.makeToast("删除账户成功！");
                view.refreshPage();
            }

            //网络请求失败
            @Override
            public void onFailure(String msg, String code, Throwable e) {
                super.onFailure(msg, code, e);
                view.makeToast(msg);
            }

            //加载结束
            @Override
            public void onNetworkFail() {
                super.onNetworkFail();
                view.onNetworkFail();
            }

            //加载中
            @Override
            public void onFinish() {
                super.onFinish();
                view.hideProcessingIndicator();
            }
        });
    }


    @Override
    public void onStart() {
        mService = new MineService();
    }
}
